[#244][#245] Zap v2 frontend: multi-token lib + UI#436
Conversation
#245: Rewrite lib/zap.ts for ZapPlotLinkV2 multi-token ABI: - New ABI: mint(fromToken, storylineToken, ...), mintReverse(...), estimateMint(...), estimateMintReverse(...) - getZapQuote calls contract estimates via simulateContract (non-view) - buildZapMintTx handles ETH (payable) vs ERC-20 (approval) paths - Removed V4 Quoter calls — contract handles full path internally - 3% slippage buffer on bonding curve execution Update constants.ts: - ZAP_PLOTLINK mainnet: 0xEF6a8640c836b16Eb8cCD8016Ead4C8517aC3033 - Added USDC, HUNT, ETH_ADDRESS constants - Added SUPPORTED_ZAP_TOKENS list for frontend selector #244: Multi-token selector on TradingWidget buy tab: - 4 options: ETH, USDC, HUNT, PLOT (default: ETH) - ETH: payable zap tx, no approval, balance via useBalance - USDC/HUNT: approve to ZAP_PLOTLINK → zap tx, balance via balanceOf - PLOT: existing direct MCV2_Bond.mint flow unchanged - USDC handled as 6 decimals for balance display - Sell tab: unchanged - Trade indexing fires for all modes - isZapAvailable hides selector when zap address is zero Fixes #244, Fixes #245 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: REQUEST CHANGES
Summary
The mainnet path looks directionally right, but this PR regresses the existing Sepolia/testnet frontend by wiring the new V2 ABI against the old V1 testnet zap address and by exposing mainnet USDC/HUNT addresses on all chains.
Findings
- [high]
lib/zap.tsnow always uses the V2 ABI, butZAP_PLOTLINKstill points to the old Sepolia V1 contract on testnet. On Base Sepolia,getZapQuote()/buildZapMintTx()will callestimateMint/mint(fromToken,...)against0xC7C47D..., which is the previous ETH-only zap and does not match this ABI. That breaks the existing testnet zap flow instead of preserving it.- File:
lib/contracts/constants.ts:37 - Suggestion: either gate the V2 frontend to mainnet only (hide zap modes on testnet), or deploy/update a matching Sepolia V2 zap address before switching the frontend ABI globally.
- File:
- [high]
USDC,HUNT, andSUPPORTED_ZAP_TOKENSare exported unconditionally with Base mainnet token addresses. Because the widget only checks whetherZAP_PLOTLINKis nonzero, Base Sepolia users will still see USDC/HUNT options and the app will check balances / approvals against mainnet token contracts on the wrong chain.- File:
lib/contracts/constants.ts:55 - Suggestion: make the supported zap token list chain-aware, or suppress non-PLOT zap options on testnet until Sepolia addresses and a matching zap deployment exist.
- File:
Decision
Requesting changes because this PR introduces a cross-network frontend regression even if the mainnet integration itself is correct.
…2 ABI Set testnet ZAP_PLOTLINK to zero address until a V2 contract is deployed to Base Sepolia. This prevents the V2 frontend from calling V2 ABI functions against the old V1 Sepolia deployment. The isZapAvailable check in TradingWidget already hides the token selector when ZAP_PLOTLINK is zero, so testnet users fall back to direct PLOT mode only. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
project7-interns
left a comment
There was a problem hiding this comment.
T2b Review — APPROVED
No blockers. Core logic is solid across all three files.
Verified correct
- ABI signatures match ZapPlotLinkV2 contract ✓
simulateContractused for non-view estimates ✓- ETH: payable with msg.value, no approval ✓
- USDC/HUNT: allowance check → approve → mint (two-step) ✓
- USDC 6 decimals handled correctly ✓
- 3% slippage buffer applied correctly ✓
- PLOT direct path unchanged ✓
- Sell tab unchanged ✓
- V4 Quoter calls fully removed ✓
- Trade indexing fires for all modes ✓
- isZapAvailable hides non-PLOT options when zap is zero ✓
- No dead code from v1 ✓
- Constants match spec ✓
WARN (non-blocking)
-
Button label when zap unavailable: When
isZapAvailableis false,payTokendefaults to "ETH" butisPlotModeis true — button says "Buy with ETH" instead of "Buy with PLOT". Trade executes correctly, just label is misleading. -
Stale
useCallbackdep:refetchBalancecapturesisEthModebut doesn't list it in dependencies. Could cause stale refetch when switching pay tokens.
project7-interns
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Summary
The Sepolia gating fix resolves the cross-network regression, and the updated multi-token frontend wiring is consistent with the deployed V2 contract. CI is green.
Findings
- No blocking findings.
Decision
Approving because the mainnet multi-token zap flow is wired correctly, testnet is safely gated off, and the build is passing.
Summary
lib/zap.tsfor ZapPlotLinkV2 multi-token ABI. Removed V4 Quoter calls — contract estimates handle full path. Added USDC/HUNT/ETH_ADDRESS constants andSUPPORTED_ZAP_TOKENS. Updated mainnetZAP_PLOTLINKto0xEF6a8640c836b16Eb8cCD8016Ead4C8517aC3033.Test plan
Fixes realproject7/agent-os#244, Fixes realproject7/agent-os#245
🤖 Generated with Claude Code